package com.zhanglifan.service.impl;

import com.zhanglifan.dao.BaseDao;
import com.zhanglifan.service.BaseService;
import com.zhanglifan.util.Page;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

public class BaseServiceImpl<T> implements BaseService<T> {

    protected BaseDao baseDao;

    public void setBaseDao(BaseDao baseDao) {
        this.baseDao = baseDao;
    }

    @Override
    public List<T> find(String hql, Class<T> entityClass, Object[] params) {
        return baseDao.find(hql,entityClass,params);
    }

    @Override
    public T get(Class<T> entityClass, Serializable id) {
        return (T) baseDao.get(entityClass,id);
    }

    @Override
    public Page<T> findPage(String hql, Page<T> page, Class<T> entityClass, Object[] params) {
        return baseDao.findPage(hql,page,entityClass,params);
    }

    @Override
    public void saveOrUpdate(T entity) {
        baseDao.saveOrUpdate(entity);
    }

    @Override
    public void saveOrUpdateAll(Collection<T> entitys) {
        baseDao.saveOrUpdateAll(entitys);
    }

    @Override
    public void deleteById(Class<T> entityClass, Serializable id) {
        baseDao.deleteById(entityClass,id);
    }

    @Override
    public void delete(Class<T> entityClass, Serializable[] ids) {
        baseDao.delete(entityClass,ids);
    }
}
